//
//  LGTRWZStepCellBottomView.swift
//  KJLGT
//
//  Created by jenkin on 2019/8/25.
//  Copyright © 2019年 jenkin. All rights reserved.
//

import UIKit

class LGTRWZStepCellBottomView: UIView {
    var clickIndex:ClickIndexBlock?
    
    //delete  movedown moveupward edit
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.white
        let imageLine:UIImageView = LGTViewCreateUtil.share.createLineView()
        self.addSubview(imageLine)
        imageLine.backgroundColor = ColorUtil(color: 0xEFEFEF)
        imageLine.snp.makeConstraints { (make) in
            make.left.equalTo(SizeFit(13))
            make.right.equalTo(-SizeFit(11))
            make.height.equalTo(1)
            make.top.equalTo(0)
        }
        
        let data:Array<Dictionary<String, String>> = [["image":"delete", "title":"删除"],
                                                      ["image":"movedown", "title":"下移"],
                                                      ["image":"moveupward", "title":"上移"],
                                                      ["image":"edit", "title":"编辑"]
        ]
        let count:Int = data.count
        let x0:Double = SizeFit(24)
        let itemW:Double = (Double(KScreenW) - (2 * x0)) / Double(count)
        let itemH:Double = SizeFit(36)
        for i in 0..<data.count{
            let dict = data[i]
            let image:String = dict["image"] ?? ""
            let title:String = dict["title"] ?? ""
            let  button:UIButton = LGTViewCreateUtil.share.createButtonTitleAndImage(imageName: image, title: title, color: TextColor, font: Font_Normal_12, backColor: UIColor.clear, left:SizeFitFloat(6))
            button.tag = i
            self.addSubview(button)
            button.addTarget(self, action: #selector(gotoAction), for: UIControl.Event.touchUpInside)
            button.snp.makeConstraints { (make) in
                make.left.equalTo(x0 + Double(i) * itemW)
                make.width.equalTo(itemW)
                make.height.equalTo(itemH)
                make.top.equalTo(1)
            }
        }
        
        let yellowLine:UIImageView = LGTViewCreateUtil.share.createLineView()
        self.addSubview(yellowLine)
        yellowLine.backgroundColor = YellowColor
        yellowLine.snp.makeConstraints { (make) in
            make.left.equalTo(SizeFit(13))
            make.right.equalTo(-SizeFit(11))
            make.height.equalTo(1)
            make.bottom.equalTo(0)
        }
    }
    
    @objc func gotoAction(sender:UIButton){
        if self.clickIndex != nil{
            self.clickIndex!(sender.tag)
        }
    }
}
